package com.ticket.sass.common.ticketserver

import com.ticket.sass.common.ticketserver.configure.Config
import com.ticket.sass.common.ticketserver.configure.ConfigData
import com.ticket.sass.common.ticketserver.dto.input.*
import com.ticket.sass.common.ticketserver.enums.Platform
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest

@SpringBootTest
class CommonTicketserverApplicationTests {

    @Autowired
    lateinit var ticketServerBuilder: TicketServerBuilder

    @Test
    fun contextLoads() {
    }

    @Test
    fun testTicketServer() {
        val res = ticketServerBuilder.apiBuild(Config(
            Platform.FHYZ,
            ConfigData.Fhyz(
                "JPKJ",
                "16777",
                "034FDB7FA4EFC38D944B28354FF71941"
            )
        )).schedules(ScheduleInput())

        println(res)
    }

    @Test
    fun testHalls() {
        val res = ticketServerBuilder.apiBuild(Config(
            Platform.FHYZ,
            ConfigData.Fhyz(
                "JPKJ",
                "16777",
                "034FDB7FA4EFC38D944B28354FF71941"
            )
        )).halls()

        println(res)
    }

    @Test
    fun testCx30ScheduleList() {
        val res = ticketServerBuilder.apiBuild(Config(
            Platform.CX30,
            ConfigData.CX30(
                "TESTUSER",
                "44001971",
                "e10adc3949ba59abbe56e057f20f883e"
            )
        )).schedules(ScheduleInput("2024-05-17", "2024-05-20"))

        println(res)
    }

    @Test
    fun testCx30ScheduleSeatMap() {
        val res = ticketServerBuilder.apiBuild(Config(
            Platform.CX30,
            ConfigData.CX30(
                "TESTUSER",
                "44001971",
                "e10adc3949ba59abbe56e057f20f883e"
            )
        )).scheduleSeatMap(ScheduleSeatMapInput(
            "6927202405170035",
            hallCode = "0000000000000004"
        ))

        println(res)
    }

    @Test
    fun testCx30SeatLock() {
        val res = ticketServerBuilder.apiBuild(Config(
            Platform.CX30,
            ConfigData.CX30(
                "TESTUSER",
                "44001971",
                "e10adc3949ba59abbe56e057f20f883e"
            )
        )).seatLock(SeatLockInput(
            "6927202405180035",
            "6927202405180035",
            "",
            listOf(
                SeatLockInput.Seat("4400197104#02#12", "4400197104#02#12"),
            )
        ))

        println(res)
    }

    @Test
    fun testCx30SeatUnlock() {
        val res = ticketServerBuilder.apiBuild(Config(
            Platform.CX30,
            ConfigData.CX30(
                "TESTUSER",
                "44001971",
                "e10adc3949ba59abbe56e057f20f883e"
            )
        )).seatUnlock(SeatUnlockInput(
            "6927240518000010",
            "6927202405180035",
            "",
            listOf(
                SeatUnlockInput.Seat("4400197104#01#14", "4400197104#01#14"),
            )
        ))

        println(res)
    }

    @Test
    fun testCx30OrderTicketSubmit() {
        val res = ticketServerBuilder.apiBuild(Config(
            Platform.CX30,
            ConfigData.CX30(
                "TESTUSER",
                "44001971",
                "e10adc3949ba59abbe56e057f20f883e"
            )
        )).orderTicketSubmit(
            OrderTicketSubmitInput(
            "6927240519000017",
                "6927240519000017",
            "6927202405190039",
            "6927202405190039",
                "",
                "13377889998",
                listOf(
                    OrderTicketSubmitInput.Seat(
                        "4400197104#02#06",
                        "4400197104#02#06",
                        45.toBigDecimal(),
                        0.toBigDecimal(),
                        1.toBigDecimal(),
                        1.toBigDecimal()
                    ),
                )
            )
        )

        println(res)
    }

    @Test
    fun testCx30OrderTicketStatus() {
        val res = ticketServerBuilder.apiBuild(Config(
            Platform.CX30,
            ConfigData.CX30(
                "TESTUSER",
                "44001971",
                "e10adc3949ba59abbe56e057f20f883e"
            )
        )).orderTicketStatus(
            OrderTicketStatusInput(
                "6927240519000014",
                "6927240519000014",
            )
        )
    }

    @Test
    fun testCx30OrderTicketInfo() {
        val res = ticketServerBuilder.apiBuild(Config(
            Platform.CX30,
            ConfigData.CX30(
                "TESTUSER",
                "44001971",
                "e10adc3949ba59abbe56e057f20f883e"
            )
        )).orderTicketInfo(
            OrderTicketInfoInput("4400197151421077")
        )

        println(res)
    }

    @Test
    fun testCx30CancelOrder() {
        val res = ticketServerBuilder.apiBuild(Config(
            Platform.CX30,
            ConfigData.CX30(
                "TESTUSER",
                "44001971",
                "e10adc3949ba59abbe56e057f20f883e"
            )
        )).orderTicketRefund(
            OrderTicketRefundInput("4400197181451369|1444501031697918", "", "", listOf())
        )
    }
}
